import { useState, useEffect } from 'react';

export const App = () => {
  const [count, setCount] = useState(0);
  // 组件渲染完毕后执行一个副作用
  useEffect(() => {
    console.log('我这个Effect只在组件渲染完毕后执行一次');
    setInterval(() => {
      console.log('计时器');
    }, 1000);
  }, []);

  return (
    <div>
      <h2>组件只在渲染完毕后执行一次Effect</h2>
      <h2>{count}</h2>
      <button onClick={() => setCount(count + 1)}>+1</button>
    </div>
  );
};
